package cn.stylefeng.guns.modular.system.exception;


import cn.stylefeng.guns.modular.system.enums.ResultEnum;

/**
 * @Author: lzy
 * @Description: 全局异常处理
 * @Date: CREATE IN 2019/5/17 10:39
 */
public class ProjectException extends RuntimeException {
    private Integer code;

    //给一个错误信息
    public ProjectException(ResultEnum resultEnum){
        super(resultEnum.getMessage());
        code = resultEnum.getCode();
    }

    //为了代码健壮 使用检测注解@Valid与  BindingResult对象（bindingResult.getFieldError().getDefaultMessage()）
    public ProjectException(Integer code, String message) {
        super(message);
        this.code = code;
    }

    public ProjectException(String msg) {
        super(msg);
        this.code = 501;
    }

    public ProjectException(Integer status, Exception e) {
        super(e);
        this.code = 501;
        this.code = status;
    }

    public ProjectException(Exception e) {
        super(e);
        this.code = 501;
    }

    public void setStatus(Integer status) {
        this.code = status;
    }

}
